import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;

public class boot {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        //配置加载路径
        URL dir = HashTabDemo.class.getProtectionDomain().getCodeSource().getLocation();
        URL dir2 = Emp.class.getProtectionDomain().getCodeSource().getLocation();
        URL dir3 = HashTab.class.getProtectionDomain().getCodeSource().getLocation();
        URL dir4 = EmpLinkedList.class.getProtectionDomain().getCodeSource().getLocation();
        //把要用的类全部加载到自定义加载器
        MyClassLoader loader = new MyClassLoader(new URL[]{dir,dir2,dir4,dir3},ClassLoader.getSystemClassLoader());
//        System.out.println(loader);
        //获取主类的信息
        Class<?> cla = Class.forName("HashTabDemo",true,loader);
        //获取主类的无参构造函数并实例化
        Object obj = cla.getDeclaredConstructor().newInstance();
        //获取主方法，运行并传递加载器
        Method method = cla.getMethod("doMain", MyClassLoader.class);
        method.invoke(obj,loader);
    }
}
